package com.xiaren.ui.tree;

import javax.swing.text.Document;
import javax.swing.tree.DefaultMutableTreeNode;

import com.xiaren.common.ObjectConstant;

/**
 * @主页 http://www.leaf123.cn/
 * @邮箱 xia5523@qq.com
 */
public class JTreeNode extends DefaultMutableTreeNode {

	public long treeNodeId = 0;
	public long parentId = 0;
	public String noteName = null;
	public Document document = null;
	public boolean ifFind = false;// 是否找到
	private String password;	//密码

	public JTreeNode() {
	}

	public JTreeNode(String noteName, long parentId) {
		super(noteName);
		treeNodeId = System.currentTimeMillis();
		this.parentId = parentId;
		this.noteName = noteName;
	}

	public JTreeNode(long treeNoteId, long parentId, String noteName) {
		this(noteName, parentId);
		this.treeNodeId = treeNoteId;
	}

	public JTreeNode(long treeNoteId, long parentId, String noteName, Document document) {
		this(noteName, parentId);
		this.treeNodeId = treeNoteId;
		this.document = document;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof JTreeNode) {
			JTreeNode new_name = (JTreeNode) obj;
			return new_name.treeNodeId == this.treeNodeId;
		} else {
			return false;
		}
	}

	public String getPassword() {
		if(password == null){
			return "";
		}
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Override
	public int hashCode() {
		return (int) treeNodeId;
	}

	@Override
	public String toString() {
//		return this.userObject + "," + this.treeNodeId + "," + this.parentId;
		return super.toString();
	}

	public String sayMySelf() {
		return "this.Class=" + this.getClass() + ",treeNodeId="
				+ this.treeNodeId + ",parentId=" + parentId + ",ifFind="
				+ ifFind + ",userObject=" + userObject;
	}
}
